﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace WebApp.App.Web.Default.Channel
{
    public class IndexAction  : Controller
	{
		public IndexAction(System.IO.TextWriter tw):base(tw){}
		public IndexAction(string fileName) : base(fileName) {}
		public IndexAction(Controller controller):base(controller){}
		public IndexAction(NRapid.Owin.HtmlWriter writer,IDictionary<string,string> cookies):base(writer,cookies){}
        public void Index(int id)
        {
            Code.Cms.Channel channel = new Code.Cms.Channel();
            this.channel= channel.GetValue(id.ToString());
            #region 根据不同的频道调用不同的模板
            if (this.channel.type_id == 1)
            {
                Web.Default.Channel.ArticleAction control = new Web.Default.Channel.ArticleAction(this);                
                control.Before();
                control.Article();
                control.After();
                control.Dispose();
            }
            else if (this.channel.type_id == 2)
            {
                Web.Default.Channel.AttachmentAction control = new Web.Default.Channel.AttachmentAction(this);
                control.Before();
                control.Attachment();
                control.After();
                control.Dispose();
            }
            else if (this.channel.type_id == 3)
            {
                Web.Default.Channel.ImageAction control = new Web.Default.Channel.ImageAction(this);
                control.Before();
                control.Image();
                control.After();
                control.Dispose();
            }
            else if (this.channel.type_id == 4)
            {
                Web.Default.Channel.CommentAction control = new Web.Default.Channel.CommentAction(this);
                control.Before();
                control.Comment();
                control.After();
                control.Dispose();
            }
            #endregion
        }
        
        
        
        
    }
}